package service;

import java.io.Serializable;

/**
 * @author yuzk
 * @date 2018/1/17
 */
public class Result implements Serializable{

    private Integer code;
    private String errorMessage;
    private Object data;

    public Integer getCode() {
        return code;
    }

    public Result setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public Result setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
        return this;
    }

    public Object getData() {
        return data;
    }

    public Result setData(Object data) {
        this.data = data;
        return this;
    }

    public static Result success(Object object) {
        return success().setData(object);
    }
    public static Result success() {
        return new Result().setCode(0);
    }
    public static Result error() {
        return new Result().setCode(-1);
    }
    public static Result error(String errorMessage) {
        return error().setErrorMessage(errorMessage);
    }
}
